﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Core.SimpleTemp.Application.Common;
using Core.SimpleTemp.Mvc.Api.Internal;
using Core.Toolkit.Core;
using Core.Toolkit.Core.Api;
using Core.Toolkit.Core.Model;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Core.SimpleTemp.Api.Api.Common 
{
    /// <summary>
    /// 获取已部门为层级的用户数据
    /// </summary>
    [ApiExplorerSettings(GroupName = "Sys")]
    [Route("api/[controller]")]
    [EnableCors("any")]
    [Authorize]
    [ApiController]
    public class TreeController : CoreApiController
    {

        private readonly DepartmentStaffService _departmentStaff;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="departmentStaff"></param>
        public TreeController(DepartmentStaffService departmentStaff) 
        {
            _departmentStaff = departmentStaff;
        }



        /// <summary>
        /// 获取已部门为层级的用户数据
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetTreeDepartmentStaff")]
        public ActionResult GetTreeDepartmentStaff()
        {
            var datatabe = _departmentStaff.GetData(DepartmentType.All, UserIdentity.Factory);
            return this.JsonSuccess(datatabe);
        }

        /// <summary>
        /// 获取整改确认人
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetTreeEnsure")]
        public ActionResult GetTreeEnsure()
        {
            var datatabe = _departmentStaff.GetData(DepartmentType.Ensure);
            return this.JsonSuccess(datatabe);
        }
        /// <summary>
        /// 获取整改负责人
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetTreePersonInCharge")]
        public ActionResult GetTreePersonInCharge()
        {
            var datatabe = _departmentStaff.GetData(DepartmentType.PersonInCharge);
            return this.JsonSuccess(datatabe);
        }
        /// <summary>
        /// 获取整改人
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetTreeRectification")]
        public ActionResult GetTreeRectification()
        {
            var datatabe = _departmentStaff.GetData(DepartmentType.Rectification);
            return this.JsonSuccess(datatabe);
        }


        /// <summary>
        /// 获取已部门为层级的双总部用户数据
        /// </summary>
        /// <returns></returns>
        [HttpGet("GetTreeDoubleDepartmentStaff")]
        public ActionResult GetTreeDoubleDepartmentStaff()
        {
            var datatabe = _departmentStaff.GetDataDouble();
            return this.JsonSuccess(datatabe);
        }

    }
}